package com.googlecode.fahview.v6project.panels;

/*
 * #%L
 * This file is part of FAHView-v6project.
 * %%
 * Copyright (C) 2011 - 2013 Michael Thomas <mikepthomas@outlook.com>
 * %%
 * FAHView is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * %
 * FAHView is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * %
 * You should have received a copy of the GNU General Public License
 * along with FAHView.  If not, see <http://www.gnu.org/licenses/>.
 * #L%
 */

import com.googlecode.fahview.v6project.utilities.LogReader;
import com.googlecode.fahview.v6project.utilities.ProgressCellRenderer;
import javax.swing.JTable;

/**
 * The main User Interface of the FAHView program.
 *
 * @author <a href="mailto:mikepthomas@outlook.com">Michael Thomas</a>
 * @version $Id: $Id
 */
public class QueuePanel extends javax.swing.JPanel {

    /**
     * Creates new form QueuePanel
     */
    public QueuePanel() {
        initComponents();

        table.getColumn("Progress").setCellRenderer(new ProgressCellRenderer());
    }

    /**
     * Get this QueuePanel table instance
     *
     * @return JTable table
     */
    public JTable getTable() {
        return table;
    }

    /**
     * Set the Status value in the QueuePanel table to a specified value at the
     * required position
     *
     * @param position location in the table to change value.
     * @param value the value to change to
     */
    protected void setStatus(int position, int value) {
        table.getModel().setValueAt(value, position, 1);
    }

    /**
     * Set the Percentage value in the QueuePanel table to a specified value at the
     * required position
     *
     * @param position location in the table to change value.
     * @param value the value to change to
     */
    protected void setPercentage(int position, String value) {
        table.getModel().setValueAt(value, position, 2);
    }

    /**
     * Set the Project value in the QueuePanel table to a specified value at the
     * required position
     *
     * @param position location in the table to change value.
     * @param value the value to change to
     */
    protected void setProject(int position, String value) {
        table.getModel().setValueAt(value, position, 3);
    }

    /**
     * Set the Issue time for the current work unit
     *
     * @param issued the issue time for current work unit
     */
    protected void setIssued(String issued) {
        this.issued.setText(issued);
    }

    /**
     * Set the Work server for the current work unit
     *
     * @param workServer the work server for current work unit
     */
    protected void setWorkServer(String workServer) {
        this.workServer.setText(workServer);
    }

    /**
     * Set the Collection server for the current work unit
     *
     * @param collectionServer the collection server for current work unit
     */
    protected void setCollectionServer(String collectionServer) {
        this.collectionServer.setText(collectionServer);
    }

    /**
     * Set the User Name for the current work unit
     *
     * @param userName the user name for current work unit
     */
    protected void setUserName(String userName) {
        this.userName.setText(userName);
    }

    /**
     * Set the Team Number for the current work unit
     *
     * @param teamNumber the team number for current work unit
     */
    protected void setTeamNumber(String teamNumber) {
        this.teamNumber.setText(teamNumber);
    }

    /**
     * Set the Core Type for the current work unit
     *
     * @param core the core type for current work unit
     */
    protected void setCore(String core) {
        this.core.setText(core);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        queueWindow = new javax.swing.JScrollPane();
        table = new javax.swing.JTable();
        currentWU = new javax.swing.JInternalFrame();
        issuedLabel = new javax.swing.JLabel();
        workServerLabel = new javax.swing.JLabel();
        collectionServerLabel = new javax.swing.JLabel();
        UserNameLabel = new javax.swing.JLabel();
        TeamNumberLabel = new javax.swing.JLabel();
        issued = new javax.swing.JLabel();
        workServer = new javax.swing.JLabel();
        collectionServer = new javax.swing.JLabel();
        userName = new javax.swing.JLabel();
        teamNumber = new javax.swing.JLabel();
        coreLabel = new javax.swing.JLabel();
        core = new javax.swing.JLabel();

        table.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {"0", null, "0%", null},
                {"1", null, "0%", null},
                {"2", null, "0%", null},
                {"3", null, "0%", null},
                {"4", null, "0%", null},
                {"5", null, "0%", null},
                {"6", null, "0%", null},
                {"7", null, "0%", null},
                {"8", null, "0%", null},
                {"9", null, "0%", null}
            },
            new String [] {
                "Position", "Status", "Progress", "Project"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.Integer.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                true, false, true, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        table.setEnabled(false);
        queueWindow.setViewportView(table);

        currentWU.setVisible(true);

        issuedLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        org.openide.awt.Mnemonics.setLocalizedText(issuedLabel, org.openide.util.NbBundle.getMessage(QueuePanel.class, "QueuePanel.issuedLabel.text")); // NOI18N

        workServerLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        org.openide.awt.Mnemonics.setLocalizedText(workServerLabel, org.openide.util.NbBundle.getMessage(QueuePanel.class, "QueuePanel.workServerLabel.text")); // NOI18N

        collectionServerLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        org.openide.awt.Mnemonics.setLocalizedText(collectionServerLabel, org.openide.util.NbBundle.getMessage(QueuePanel.class, "QueuePanel.collectionServerLabel.text")); // NOI18N

        UserNameLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        org.openide.awt.Mnemonics.setLocalizedText(UserNameLabel, org.openide.util.NbBundle.getMessage(QueuePanel.class, "QueuePanel.UserNameLabel.text")); // NOI18N

        TeamNumberLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        org.openide.awt.Mnemonics.setLocalizedText(TeamNumberLabel, org.openide.util.NbBundle.getMessage(QueuePanel.class, "QueuePanel.TeamNumberLabel.text")); // NOI18N

        coreLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        org.openide.awt.Mnemonics.setLocalizedText(coreLabel, org.openide.util.NbBundle.getMessage(QueuePanel.class, "QueuePanel.coreLabel.text")); // NOI18N

        org.jdesktop.layout.GroupLayout currentWULayout = new org.jdesktop.layout.GroupLayout(currentWU.getContentPane());
        currentWU.getContentPane().setLayout(currentWULayout);
        currentWULayout.setHorizontalGroup(
            currentWULayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(currentWULayout.createSequentialGroup()
                .addContainerGap()
                .add(currentWULayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                    .add(currentWULayout.createSequentialGroup()
                        .add(6, 6, 6)
                        .add(coreLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, UserNameLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(issuedLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(workServerLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(collectionServerLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, TeamNumberLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(currentWULayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(issued, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(workServer, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(collectionServer, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(userName, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(teamNumber, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(core, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 129, Short.MAX_VALUE))
                .addContainerGap())
        );
        currentWULayout.setVerticalGroup(
            currentWULayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(currentWULayout.createSequentialGroup()
                .addContainerGap()
                .add(currentWULayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                    .add(issuedLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(issued, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(currentWULayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                    .add(workServerLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(workServer, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(currentWULayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                    .add(collectionServerLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(collectionServer, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(currentWULayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                    .add(UserNameLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(userName, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(currentWULayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(TeamNumberLabel)
                    .add(teamNumber, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 16, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(currentWULayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(coreLabel)
                    .add(core, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 16, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(110, Short.MAX_VALUE))
        );

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(queueWindow, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 320, Short.MAX_VALUE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(currentWU, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(currentWU)
                    .add(queueWindow, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel TeamNumberLabel;
    private javax.swing.JLabel UserNameLabel;
    private javax.swing.JLabel collectionServer;
    private javax.swing.JLabel collectionServerLabel;
    private javax.swing.JLabel core;
    private javax.swing.JLabel coreLabel;
    private javax.swing.JInternalFrame currentWU;
    private javax.swing.JLabel issued;
    private javax.swing.JLabel issuedLabel;
    private javax.swing.JScrollPane queueWindow;
    private javax.swing.JTable table;
    private javax.swing.JLabel teamNumber;
    private javax.swing.JLabel userName;
    private javax.swing.JLabel workServer;
    private javax.swing.JLabel workServerLabel;
    // End of variables declaration//GEN-END:variables
}
